package cn.wolfcode.luowowo.article.domain;


import cn.wolfcode.luowowo.common.domain.BaseDomain;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

@Setter
@Getter
public class DestinationTheme extends BaseDomain {

    private String name;

    private Long siftingId;

    private String coverUrl;

    private String refDest;

    private Long[] refDestIds;

    public String getRef() {
        if (refDestIds == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        for (Long id : refDestIds) {
            sb.append(id).append(",");
        }
        sb.deleteCharAt(sb.length() - 1);
        refDest = sb.toString();
        return refDest;
    }

    public Long[] getRefIds() {
        if (!StringUtils.hasLength(refDest)) {
            return null;
        }
        String[] vals = refDest.split(",");
        refDestIds = new Long[vals.length];
        for (int i = 0; i < vals.length; i++) {
            refDestIds[i] = Long.valueOf(vals[i]);
        }
        return refDestIds;
    }
}